<?php

require_once('../const.php');

class Authorization
{
		
	function Authorization(){

    	session_start();
  	}

  	function login($username, $password){
    
    	$_SESSION['username'] = $username;
    	$_SESSION['password'] = $password;

    	if ($_SESSION['username'] == USERNAME && $_SESSION['password'] == PASSWORD){
      		return true;
    	}
    	else{
     		$this->logout();
     		return false;
    	}
  	}

  	function checkLogin(){
  
    	if (isset($_SESSION['username']))
      		return true;
      
    	return false;
  	}

  	function logout(){

    	session_destroy();
    	header("Location: index.php");
  	}
  	
  	public function getUsername(){
  		return $_SESSION['username'];
  	}
}
$session = new Authorization()
?>